<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>修改手机号</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no"/>
	    <meta http-equiv="Access-Control-Allow-Origin" content="*">
	    <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
		<link rel="stylesheet" href="../css/base.css" />
		<link rel="stylesheet" href="../css/forgetPaymentPassword.css" />

	</head>
	<body>
		<div class="header">
			<a href="javascript:history.back(-1)"><img src="../img/g_next.png" alt="" /></a>
			手机号修改
		</div>
		<div style="height: 0.44rem;"></div>
		<div class="forgetPaymentPassword_main">
			<p class="tishi">修改手机号前需验证当前手机号</p>
			<ul class="set_zhifupassword_main">
				<li class="set_zhifupassword_main_li">
					<span class="title">手机号</span>
					<input type="text" class="newPhone" placeholder="请输入原手机号" />
				</li>
				<li class="set_zhifupassword_main_li">
					<input type="text" class="gold-password" name="verify" placeholder="请输入短信验证码">
					<span class="fold-verify">发送验证码</span>
					<span class="fold-ver">60</span>
				</li>
			</ul>
		</div>
		<input type="button" value="下一步" class="set_password_btn" />
	</body>
	<script src="../js/jquery-2.2.3.min.js"></script>
	<script type="text/javascript" src="../js/rem.js"></script>
	<script src="../js/common.js"></script>
	<script>
		$(".fold-verify").click(function(){
			
			var newPhone = $('.newPhone').val();
				code = $('input[name="verify"]').val(),

			$.ajax({
                url:SURL+'/jfd/users/getCode',
                type:'post',
                data:{
                    userId: localStorage.getItem('userId'),
					userPhone:newPhone,
					type:3,
                },
                dataType:'json',
                success:res=>{
					
					if(res.code == 0){
						$('.fold-verify').css("display","none")
                       $('.fold-ver').css("display","block")
                        var time=60;
                        setTime=setInterval(function(){
                            if(time<=0){
                                clearInterval(setTime);
                                $('.fold-verify').css("display","block")
                                $('.fold-ver').css("display","none")
                                return;
                            }
                            time--;
                            $(".fold-ver").text(time);
                        },1000);
					}else{
						alert(res.msg);
					}
				
                },error:res=>{
					alert(res.msg);
				
				}
            })
		})
		$('.set_password_btn').click(function() {
			var newPhone = $('.newPhone').val();
		    	code = $('input[name="verify"]').val();
            $.ajax({
                url:SURL+'/jfd/users/checkCode',
                type:'post',
                data:{
					userPhone:newPhone,
					type:3,
					code:code
                },
                dataType:'json',
                success:res=>{
					if(res.code == 0){
						location.href = 'xiugai_newtel.html'
					}else{
						alert(res.msg);
					}
                  
                },error:res=>{
                    alert(res.msg);
				}
            })
		})

	</script>
</html>
